const jwt = require('jsonwebtoken');
require('dotenv').config();

console.log('JWT_SECRET from env:', process.env.JWT_SECRET);

// 生成一个测试token
const testToken = jwt.sign(
  { userId: 1, username: 'testuser' },
  process.env.JWT_SECRET,
  { expiresIn: '24h' }
);

console.log('Generated token:', testToken);

// 验证token
try {
  const decoded = jwt.verify(testToken, process.env.JWT_SECRET);
  console.log('Decoded token:', decoded);
} catch (error) {
  console.error('Token verification error:', error);
}